package com.oplink.webems.common.snmp.base;

public class SnmpException extends Exception {
	private static final long serialVersionUID = -2293855036288823985L;
	
	public final static String VALID_NAME_ERROR = "oid_match_name_error";
	
	public final static String COMM_HASNORESPONSE = "communicate_has_no_response";
	public final static String COMM_SYS_ERROR = "communicate_io/sys_error";
	public final static String COMM_READ_ERROR = "communicate_read_error";
	public final static String COMM_WRITE_ERROR = "communicate_write_error";
	
	private String oid;
	private String value;
	private String ip;
	private String snmpCause;
	private String code;

	public SnmpException(String code, String ip, String oid, String value, String snmpCause){
		super(code);
		
		this.oid = oid;
		this.value = value;
		this.ip = ip;
		this.snmpCause = snmpCause;
		this.code = code;
	}
	
	public SnmpException(String code, String ip){
		this(code, ip, null,null,null);
	}
	
	public String getOid() {
		return oid;
	}

	public void setOid(String oid) {
		this.oid = oid;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}
	
	public String getSnmpCause() {
		return snmpCause;
	}

	public void setSnmpCause(String snmpCause) {
		this.snmpCause = snmpCause;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	public String getMessage() {
		String message = super.getMessage() + 
						(this.ip==null?"":":" +this.ip) + 
						(this.oid==null?"":":" + this.oid) + 
						(this.value==null?"":":" + this.value)+
						(this.snmpCause==null?"":":" + this.snmpCause);
		
		return message;
	}
}
